(function(){
try{document.body.removeChild(document.getElementById('cheatsheetArea'));}catch(e){}
var lng = ['ja','en'];
var keys = ["/","[Esc]","c","g + i","g + s","g + t","g + d","g + a","g + c"
,"[Ctrl] + s","[Tab] + [Enter]","j","k","x","* + a","* + n","* + r","* + u","* + s","* + t"
,"[Shift] + Click","o or [Enter]","u","r","a","[Shift] + i","[Shift] + u","m","y","y + o","#","!","z"
,"[Ctrl] + Click","n","p","[","]","[Shift] + n"];
var messageObj = {
	"/":
		{"ja":"検索ボックスにカーソルを移動"
		,"en":"Search"}
	,"[Esc]":
		{"ja":"現在の入力欄からカーソルを外す（全ての入力欄）"
		,"en":"Escape from input field"}
	,"c":
		{"ja":"メール作成/[Shift] + c で新しいウィンドウ"
		,"en":"Compose / [Shift] + c  in a new window"}
	,"g + i":
		{"ja":"[受信トレイ]に移動"
		,"en":"Go to 'Inbox'"}
	,"g + s":
		{"ja":"[スターあり] に移動"
		,"en":"Go to 'Starred'"}
	,"g + t":
		{"ja":"[送信済みメール] に移動"
		,"en":"Go to 'Send message'"}
	,"g + d":
		{"ja":"[下書き] に移動"
		,"en":"Go to 'Starred'"}
	,"g + a":
		{"ja":"[すべてのメール] に移動"
		,"en":"Go to 'All Mail'"}
	,"g + c":
		{"ja":"[連絡先] に移動"
		,"en":"Go to 'Contacts'"}
	,"[Ctrl] + s":
		{"ja":"メールを下書き保存"
		,"en":"Save draft"}
	,"[Tab] + [Enter]":
		{"ja":"メール送信"
		,"en":"Send message"}
	,"j":
		{"ja":"古いメールを開くかカーソルを移動/[Enter]で開く"
		,"en":"Move to older conversation"}
	,"k":
		{"ja":"新しいメールを開くかカーソルを移動/[Enter]で開く"
		,"en":"Move to newer conversation"}
	,"x":
		{"ja":"メールを選択したり選択解除する"
		,"en":"Select conversation"}
	,"* + a":
		{"ja":"全て(All)のメールを選択"
		,"en":"select all mail"}
	,"* + n":
		{"ja":"全ての選択を解除"
		,"en":"unselect all selected mail"}
	,"* + r":
		{"ja":"既読メール(Read)を選択"
		,"en":"select all read mail"}
	,"* + u":
		{"ja":"未読メール(Unread)を選択"
		,"en":"select all unread mail"}
	,"* + s":
		{"ja":"スター付きメールを選択"
		,"en":"select stared mail"}
	,"* + t":
		{"ja":"スターの無いメールを選択"
		,"en":"select not stared mail"}
	,"[Shift] + Click":
		{"ja":"<br/>メール一覧のチェックボックスを一気に選択"
		,"en":"range select"}
	,"o or [Enter]":
		{"ja":"選択したメールを開く"
		,"en":"Open"}
	,"u":
		{"ja":"更新して一覧に戻る"
		,"en":"Return to conversation list"}
	,"r":
		{"ja":"返信する/[Shift] + r で新しいウィンドウ"
		,"en":"Reply"}
	,"a":
		{"ja":"メール受信者全員に返信/[Shift] + a で新しいウィンドウ"
		,"en":"Reply all"}
	,"[Shift] + i":
		{"ja":"既読にする"
		,"en":"Mark as read"}
	,"[Shift] + u":
		{"ja":"未読にする"
		,"en":"Mark as unread"}
	,"m":
		{"ja":"スレッドをミュート"
		,"en":"mute the thread"}
	,"y":
		{"ja":"<br/>[受信トレイ]ではアーカイブ（Inboxラベル外し）<br/>[スターあり]ではスター外し<br/>ラベルではラベル外し<br/>[ゴミ箱]では[受信トレイ]に移動"
		,"en":"From 'Inbox,' 'y' means Archive <br/>From 'Starred,' 'y' means Unstar <br/>From 'Trash,' 'y' means Move to inbox <br/>From any label, 'y' means Remove the label"}
	,"y + o":
		{"ja":"アーカイブして次のスレッドに移動"
		,"en":"Archive and next"}
	,"#":
		{"ja":"メールを削除"
		,"en":"Delete"}
	,"!":
		{"ja":"迷惑メールを報告"
		,"en":"Report spam"}
	,"z":
		{"ja":"前の状態に戻す"
		,"en":"Undo"}
	,"[Ctrl] + Click":
		{"ja":"メールプレビューの表示"
		,"en":"Show mail preview"}
	,"n":
		{"ja":"スレッドビューで次にカーソルを移動"
		,"en":"Next message"}
	,"p":
		{"ja":"スレッドビューで前にカーソルを移動"
		,"en":"Previous message"}
	,"[":
		{"ja":"アーカイブして次の古いスレッドへ移動"
		,"en":"Archive and previous"}
	,"]":
		{"ja":"アーカイブして前の新しいスレッドへ移動"
		,"en":"Archive and next"}
	,"[Shift] + n":
		{"ja":"現在のスレッドを更新"
		,"en":"Update current conversation"}
};

var scripts = document.getElementsByTagName('script');
var lng = 'en';
for(var i = 0,len=scripts.length;i<len;i++){
	if(scripts[i].src.indexOf('cs_gmail_2.js') > 0){
		try{
			lng = scripts[i].src.split('?')[1].split('&')[0].split('=')[1];
		}catch(e){}
	}
}

var cheattxt = '<p style="margin:0px;width:100%;background-color:#EEEEEE">[<a id="cheatsheettoggle" href="javascript:void(0);">-</a>] <B>Gmail Cheat Sheet</B><a href="javascript:void(0);" onclick="document.body.removeChild(document.getElementById(\'cheatsheetArea\'));" style="position:absolute;right:3px">[close]</a><p>'
+'<div id="cheatsheetbody" style="overflow:auto;position:absolute;top:30px;width:330px;height:468px;padding:0px;margin:0px;display:block;">'
+'</div>';

var d = document.createElement('div');
d.id='cheatsheetArea';
d.style.position = 'absolute';
d.style.padding = '5px';
d.style.top = '20px';
d.style.right = '15px';
d.style.width = '330px';
d.style.height = '500px';
d.style.backgroundColor = '#FFFFFF';
d.style.border = '1px solid #999999';
d.style.fontSize = '10pt';
d.style.zIndex = '100000';
d.style.textAlign = 'left';
try{d.style.filter = 'alpha(opacity=90)';}catch(e){}
try{d.style.MozOpacity = '.90';}catch(e){}
try{d.style.opacity = '.90';}catch(e){}

d.innerHTML = cheattxt;
document.body.appendChild(d);
for(var i = 0,len = keys.length;i<len;i++){
	var key = keys[i];
	var appender = document.getElementById('cheatsheetbody');
	var div = document.createElement('div');
	div.innerHTML = '<label style="margin-right:10px;font-weight:bold;">' + key + '</label>' + ':<label style="color:#666666">' + messageObj[key][lng] + '</label>';
	div.style.borderTop = '1px solid #AAAAAA';
	appender.appendChild(div);
}

var a = document.getElementById('cheatsheettoggle');
a.onclick = function(){
	var b = document.getElementById('cheatsheetbody');
	var c = document.getElementById('cheatsheetArea');
	if(b.style.display == 'none'){
		b.style.display = 'block';
		c.style.height = '500px';
		a.innerHTML = '-';
	}else{
		b.style.display = 'none';
		c.style.height = null;
		a.innerHTML = '+';
	}
}
})();
